package com.example.weli.ble2test;

import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.TextView;

public class DialogWrapper {
    View base = null;
    EditText titleField = null;
    EditText valueField = null;
    CheckBox visable = null;

    DialogWrapper(View base) {
        this.base = base;
        this.valueField = (EditText) base.findViewById(R.id.setvalue);
        this.visable = (CheckBox) base.findViewById(R.id.conviable);
        this.visable.setOnCheckedChangeListener(new OnCheckedChangeListener() {
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    DialogWrapper.this.visable.setText("\u5f53\u524d\u8bbe\u7f6e\u4e3a\u53ef\u89c1");
                } else {
                    DialogWrapper.this.visable.setText("\u5f53\u524d\u8bbe\u7f6e\u4e3a\u4e0d\u53ef\u89c1");
                }
            }
        });
    }

    String getTitle() {
        return getTitleField().getText().toString();
    }

    float getValue() {
        return new Float(getValueField().getText().toString()).floatValue();
    }

    private void setvtext(String str) {
        ((TextView) this.base.findViewById(R.id.setvtext)).setText(str);
    }

    private void setttext(String str) {
        ((TextView) this.base.findViewById(R.id.setttext)).setText(str);
    }

    void setnametext(String str) {
        ((EditText) this.base.findViewById(R.id.settitle)).setText(str);
    }

    void setvaluetext(String str) {
        ((EditText) this.base.findViewById(R.id.setvalue)).setText(str);
    }

    EditText getTitleField() {
        if (this.titleField == null) {
            this.titleField = (EditText) this.base.findViewById(R.id.settitle);
        }
        return this.titleField;
    }

    EditText getValueField() {
        if (this.valueField == null) {
            this.valueField = (EditText) this.base.findViewById(R.id.setvalue);
        }
        return this.valueField;
    }

    void set_vis(boolean isv) {
        if (isv) {
            this.visable.setText("\u5f53\u524d\u8bbe\u7f6e\u4e3a\u53ef\u89c1");
            this.visable.setChecked(true);
            return;
        }
        this.visable.setText("\u5f53\u524d\u8bbe\u7f6e\u4e3a\u4e0d\u53ef\u89c1");
        this.visable.setChecked(false);
    }

    boolean read_vis() {
        return this.visable.isChecked();
    }
}
